/**
 * @Author：ming
 * @Date：2023/10/3 8:23 PM
 * @Filename：Lc1004
 */

/**
 * @author ming
 */
public class Lc1004 {
        public int longestOnes(int[] nums, int k) {
           int len = nums.length;
            int left =0;
            int right=0;
            int zero =0;
            int max =0;
            while (right<len){
                if(nums[right]==0){
                    zero++;
                }
                while (zero>k){
                    if(nums[left++]==0){
                        zero--;
                    }
                }

                max = Math.max(max,right-left+1);
                right++;

            }
            return max;
        }

}
